package com.neo.service;

import com.neo.util.DjsStringUtil;
import com.neo.util.ReadFromFile;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by admin on 2017/12/20.
 */

@Service
public class UseForUpdateProject {
    @Autowired
    private JdbcTemplate jdbcTemplate;

    public void handle() {
        List listCsv = ReadFromFile.readFileByLinesGbk(DjsStringUtil.PLAN_FILE_PATH);//改变路径
        for (int i = 1; i < listCsv.size(); i++) {
            String[] s = (String[]) listCsv.get(i);
            String payNo = s[0];
            String loanMent = s[1];
            String sql = "UPDATE jx_invest_project SET MAKE_LOAN_TIME = '" + loanMent + "' WHERE PAY_NO = '" + payNo + "'";
            jdbcTemplate.update(sql);
            System.out.println(i + "/" + listCsv.size());
        }
    }
    public void updateEnableAmt(){
        List listCsv = ReadFromFile.readFileByLinesGbk("D:/点金石/新债权信息/债权剩余金额.csv");//改变路径
        for (int i = 1; i < listCsv.size(); i++) {
            String[] s = (String[]) listCsv.get(i);
            String payNo = s[0];
            String amt = s[1];
            String sql = "UPDATE jx_invest_project SET ENABLE_AMT = " + amt + " WHERE PAY_NO = '" + payNo + "'";
            jdbcTemplate.update(sql);
            System.out.println(i + "/" + listCsv.size());
        }
    }
}
